<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        
        function dingshiqi() {
        function fun1() {
            setTimeout(()=>{
                console.log("定时器第yi个");
            },3000)
        }
        function fun2() {
            setTimeout(()=>{
                console.log("定时器第er个");
            },2000)
        }
        function fun3() {
            setTimeout(()=>{
                console.log("定时器第san个");
            },1000)
        }
        fun1();
        fun2();
        fun3();
        }

        function huidiaodiyu() {
            function sun1() {
            return new Promise((re,rt)=>{
                setTimeout(()=>{
                re("定时器第1个");
                },3000)
            })
            
        }
        function sun2() {
            return new Promise((re,rt)=>{
                setTimeout(()=>{
                re("定时器第2个");
                },2000)
            })
        }
        function sun3() {
            return new Promise((re,rt)=>{
                setTimeout(()=>{
                re("定时器第3个");
                },1000)
            })
        }
        sun1().then(res=>{
            console.log(res);
            return sun2()
        }).then(res=>{
            console.log(res);
            return sun3()
        }).then(res=>{
            console.log(res); 
        })
        }

        function generatorss() {
            function fun1() {
                setTimeout(()=>{
                    console.log("定时器第yi个");
                    fn.next();
                },3000)
            }
            function fun2() {
                setTimeout(()=>{
                    console.log("定时器第er个");
                    
                },2000)
            }
            function fun3() {
                setTimeout(()=>{
                    console.log("定时器第san个");
                    fn.next();
                },1000)
            }
       
            function*funs(){
                
                yield fun1();           
                yield fun3();         
                yield fun2();
            }
            let fn=funs();
            fn.next();

        }


        //huidiaodiyu();//三个函数按照自己的排序依次进行
        //dingshiqi();
        generatorss();
    </script>




</body>
</html>